<template>
  <div>
    <div>
      <!--  <h1>施工单位</h1> -->
      <div class="top">
        <el-dropdown>
          <el-button v-show="can_operate == '1' ? true : false">
            导入<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="showAn"
              >导入案卷目录</el-dropdown-item
            >
            <el-dropdown-item @click.native="showjuan"
              >导入卷内目录</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown>
          <el-button v-show="can_operate == '1' ? true : false">
            导出<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="Goexport"
              >导出案卷目录</el-dropdown-item
            >
            <el-dropdown-item @click.native="InGoexport"
              >导出卷内目录</el-dropdown-item
            >
            <el-dropdown-item>导出全引目录</el-dropdown-item>
            <el-dropdown-item @click.native="preparationFrom(1)"
              >导出备考表</el-dropdown-item
            >
            <el-dropdown-item @click.native="preparationFrom(2)"
              >导出案卷封面</el-dropdown-item
            >
            <el-dropdown-item @click.native="preparationFrom(3)"
              >导出盒子封面</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
        <!--  <p>当前文件是{{ Type }}   <span>{{}}</span>- <span>{{}}</span> -->
        <p>
          当前文件是{{ Type }} <span class="Seat">{{ now_location }}</span>
        </p>
      </div>
      <div class="container">
        <div class="container-left">
          <div class="input-top">
            <el-input
              placeholder="输入分类名称进行搜索"
              v-model="filterText"
              clearable
              suffix-icon="iconfont icon-sousuo2"
            >
            </el-input>
          </div>

          <div class="treePlate scroll_wrap">
            <el-tree
              class="filter-tree"
              :data="data"
              :props="defaultProps"
              default-expand-all
              node-key="id"
              :draggable="true"
              ref="tree"
              :current-node-key="currentNodeKey"
              :filter-node-method="filterNode"
              :expand-on-click-node="false"
              @node-click="handleNodeClick"
              highlight-current
            >
              <span class="custom-tree-node" slot-scope="{ node, data }">
                <span class="nodeLabel">
                  {{ node.label }}
                  <span class="nodeLefts">{{ data.data_count }}</span>
                </span>
                <span class="nodeLeft">
                  <el-button
                    class="nodeBtn"
                    size="medium"
                    type="text"
                    @click.stop="append(data)"
                  >
                    <i class="iconfont icon-xinjian"></i>
                  </el-button>
                  <el-button
                    class="nodeBtn"
                    size="medium"
                    type="text"
                    @click.stop="() => remove(node, data)"
                  >
                    <i class="iconfont icon-a-shanchu1"></i>
                  </el-button>
                  <el-tooltip
                    :content="data.archives_no"
                    placement="top"
                    effect="light"
                  >
                    <el-button
                      v-if="data.is_can_edit == 1"
                      class="nodeBtn"
                      size="medium"
                      type="text"
                      @click.stop="() => Edit(node, data)"
                    >
                      <i class="iconfont icon-a-bianji13"></i>
                    </el-button>
                  </el-tooltip>
                  <el-tooltip
                    :content="data.archives_no"
                    placement="top"
                    effect="light"
                  >
                    <el-button
                      v-if="data.is_can_edit == 0"
                      class="nodeBtns"
                      size="medium"
                      type="text"
                      @click.stop="() => Edit(node, data)"
                    >
                      <i class="iconfont icon-a-bianji13"></i>
                    </el-button>
                  </el-tooltip>
                </span>
              </span>
            </el-tree>
          </div>
        </div>
        <div class="container-right">
          <el-form :inline="true">
            <div class="commontop">
              <div class="commontop-left">
                <!-- <el-checkbox
                  label="全选"
                  :indeterminate="isIndeterminate"
                  v-model="checkAll"
                  @change="selAll()"
                ></el-checkbox> -->
                <el-input
                  placeholder="输入关键字进行搜索"
                  v-model="froms.keyword"
                  @change="INput"
                  @clear="INput"
                  @keyup.enter.native="goSearch()"
                  clearable
                  prefix-icon="el-icon-search"
                ></el-input>
                <el-button
                  class="searchbgc"
                  @click="goSearch"
                  icon="iconfont icon-sousuo2"
                  >搜索</el-button
                >
                <el-button
                  v-show="can_operate == '1' ? true : false"
                  @click="addClick()"
                  icon="iconfont icon-xinzenganjuanmulu"
                  >新增案卷</el-button
                >
                <el-button
                  v-show="can_operate == '1' ? true : false"
                  class="searchbgc"
                  @click="InspectAn"
                  >检查案卷</el-button
                >
                <el-button
                  class="searchbgc"
                  icon="iconfont icon-piliangdaorupdf"
                  v-show="can_operate == '1' ? true : false"
                  @click="fileUPList"
                  >批量导入PDF</el-button
                >
                <!--  <el-button class="searchbgc">全选</el-button> -->
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="不选中则默认全选"
                  placement="top"
                >
                  <el-button
                    class="searchbgc"
                    @click="Submission"
                    v-show="can_operate == '1' ? true : false"
                    >提交案卷审批</el-button
                  >
                </el-tooltip>
                <el-button
                  class="searchbgc"
                  v-show="can_operate == '1' ? true : false"
                  @click="Substitu"
                  >文字替换</el-button
                >
                <el-button class="searchbgc" @click="ProblemMark"
                  >问题标记</el-button
                >
                <el-button
                  v-show="can_operate == '1' ? true : false"
                  class="searchbgc"
                  @click="Pagevolume"
                  >导出卷内页码</el-button
                >
                <!-- <el-button class="searchbgc">删除</el-button> -->
              </div>
              <div class="commontop-right">
                <el-button
                  v-show="can_operate == '1' ? true : false"
                  class="red"
                  icon="iconfont icon-shanchu1"
                  @click="deleteSelectItem()"
                  >删除</el-button
                >
              </div>
            </div>
          </el-form>

          <el-table
            class="table"
            v-loading="isLoading"
            :data="tableData"
            max-height="600"
            @row-click="Rowclick"
            @row-dblclick="handleClick"
            @cell-click="tabClick"
            ref="multipleTable"
            @selection-change="handleSelectionChange"
            border
            :row-class-name="tableRowClassName"
            :cell-class-name="tableCellClassName"
            :header-cell-style="{
              backgroundColor: '#3963fd',
              color: '#fff',
              'text-align': 'center',
            }"
            style="width: 100%; margin-top: 20px"
          >
            <template slot="empty">
              <img
                src="@/assets/imgs/暂未数据.png"
                alt
                style="margin-top: 104px"
              />
              <p style="margin-top: 15px; margin-bottom: 104px">暂未有数据</p>
            </template>
            <el-table-column type="selection" width="35"></el-table-column>
            <el-table-column type="number" width="80" label="序号">
              <template slot-scope="scope">
                {{ scope.row.number }}

                <el-tooltip
                  :content="scope.row.problem"
                  v-show="scope.row.problem != ''"
                  placement="top"
                >
                  <i
                    class="el-icon-warning icons"
                    @click="Problemsolving(scope.row)"
                  ></i>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              width="220"
              prop="archives_no"
              label="档案号"
              align="center"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    class="InputTits"
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.archives_no"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>
                  {{ scope.row.archives_no }}
                  <!--  <a
                    @click="goInvolume(scope.row)"
                    style="color: blue; cursor: pointer"
                    >{{ scope.row.archives_no }}
                  </a> -->
                </div>
              </template>
            </el-table-column>

            <el-table-column
              align="left"
              prop="title"
              width="480"
              label="案卷题名"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    class="InputTit"
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.title"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div
                  v-else
                  style="color: blue; backgroundcolor: red; cursor: pointer"
                >
                  {{ scope.row.title }}
                </div>
                <!-- <div
                  class="lattice"
                  @click="goInvolume(scope.row)"
                  style="color: blue; backgroundcolor: red; cursor: pointer"
                >
                  {{ scope.row.title }}
                </div> -->
              </template>
            </el-table-column>
            <el-table-column
              width="60"
              prop="data_count"
              label="卷内数量"
              align="center"
            >
              <template slot-scope="scope">
                <div>{{ scope.row.data_count }}</div>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              width="60"
              prop="page_num"
              label="页次"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.page_num"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.page_num }}</div>
              </template>
            </el-table-column>

            <el-table-column
              align="center"
              width="60"
              prop="word_material"
              label="文字材料"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.word_material"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.word_material }}</div>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              width="60"
              prop="blueprint"
              label="蓝图"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.blueprint"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.blueprint }}</div>
              </template>
            </el-table-column>
            <el-table-column
              width="180"
              prop="start_date"
              label="起止日期"
              align="center"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.start_end_date"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.start_end_date }}</div>
              </template>
            </el-table-column>
            <el-table-column
              width="90"
              align="center"
              prop="store_period"
              label="保管期限"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-select
                    clearable
                    v-model="scope.row.store_period"
                    @change="inputBlur"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.id"
                      :label="item.title"
                      :value="item.title"
                    >
                    </el-option>
                  </el-select>
                </div>
                <div v-else>{{ scope.row.store_period }}</div>
              </template>
            </el-table-column>

            <el-table-column
              width="60"
              align="center"
              prop="cabin_no"
              label="柜号"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.cabin_no"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.cabin_no }}</div>
              </template>
            </el-table-column>
            <el-table-column label="状态">
              <template slot-scope="scope">
                <el-tag
                  type="success"
                  v-if="tableData[scope.$index].status == 0"
                  >核对中</el-tag
                >
                <el-tag
                  v-else-if="tableData[scope.$index].status == 1"
                  type="danger"
                  >待审核</el-tag
                >
                <el-tag
                  v-else-if="tableData[scope.$index].status == 2"
                  type="danger"
                  >通过</el-tag
                >
                <el-tag
                  v-else-if="tableData[scope.$index].status == 3"
                  type="danger"
                  >拒绝</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column align="center" prop="remark" label="备注">
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.index === clickRow &&
                    scope.column.index === clickCell
                  "
                >
                  <el-input
                    ref="editInput"
                    type="textarea"
                    v-model="scope.row.remark"
                    maxlength="300"
                    size="mini"
                    @blur="inputBlur"
                    @input="inputFocus"
                  />
                </div>
                <div v-else>{{ scope.row.remark }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="90px"
              v-show="can_operate == '1' ? true : false"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  class="red"
                  @click.native.prevent="deleteRow(scope.row.id)"
                  ><i class="el-icon-delete"></i
                ></el-button>
                <el-tooltip content="拆分pdf" placement="bottom" effect="light">
                  <el-button size="mini"
                    ><a
                      :href="
                        host +
                        'cut_pdf?part_company_id=' +
                        scope.row.part_company_id +
                        '&&archives_no=' +
                        scope.row.archives_no +
                        '&& project_classify_id=' +
                        scope.row.project_classify_id
                      "
                      target="_blank"
                      ><i class="iconfont icon-tianjiayijimulu"></i></a
                  ></el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>
          <div class="pagination">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="current_page"
              :page-sizes="pageSizeArr"
              :page-size="froms.per_page"
              layout="total, sizes, prev, pager, next"
              :total="total"
            >
            </el-pagination>
          </div>
        </div>
      </div>
      <el-dialog :visible.sync="dialogVisibleAmend" width="45%" class="tab">
        <el-form :model="editF" ref="editF" label-position="left">
          <el-form-item prop="title" label="分类名">
            <el-input
              v-model="editF.title"
              placeholder="请输入分类名"
            ></el-input>
          </el-form-item>
          <el-form-item prop="archives_no" class="IPBT" label="档案号">
            <el-input
              v-model="editF.archives_no"
              placeholder="请输入档案号"
              clearable
              @input="changeDang"
              @clear="setValueNull"
            >
              ></el-input
            >

            <button class="Btn" type="button" @click="ChangeIp">
              {{ Btn }}
            </button>
            <button class="Btn" type="button" @click="ChangeIps">
              {{ BTn }}
            </button>
          </el-form-item>
          <div class="list">
            <el-form-item label="种类：（必选）">
              <el-radio-group v-model="val1" @change="ChangeIp1">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list1"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="分类：（必选）">
              <el-radio-group v-model="val2" @change="ChangeIp2">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list2"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="属类：阶段代码（可选）">
              <el-radio-group v-model="val3" @change="ChangeIp3">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list3"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="属类：专业代码（可选）">
              <el-radio-group v-model="val4" @change="ChangeIp4">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list4"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
          </div>
          <div class="login-btn">
            <el-button @click="dialogVisibleAmend = false">取 消</el-button>
            <el-button type="primary" @click="editModify('editF')"
              >编辑分类</el-button
            >
          </div>
        </el-form>
      </el-dialog>
      <el-dialog
        :visible.sync="outerVisible"
        class="tab"
        title="新增分类目录"
        width="45%"
      >
        <el-form
          label-position="left"
          :rules="classFormrules"
          :model="classForm"
          ref="classForm"
        >
          <el-form-item prop="title" label="分类名称">
            <el-input
              v-model="classForm.title"
              placeholder="请输入分类名称"
            ></el-input>
          </el-form-item>
          <el-form-item prop="archives_no" class="IPBT" label="档案号">
            <el-input
              v-model="classForm.archives_no"
              placeholder="请输入档案号"
              clearable
              @input="changeDang"
              @clear="setValueNull"
            >
              ></el-input
            >

            <button class="Btn" type="button" @click="ChangeIp">
              {{ Btn }}
            </button>
            <button class="Btn" type="button" @click="ChangeIps">
              {{ BTn }}
            </button>
          </el-form-item>
          <div class="list">
            <el-form-item label="种类：（必选）">
              <el-radio-group v-model="radio1" @change="ChangeIp1">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list1"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="分类：（必选）">
              <el-radio-group v-model="radio2" @change="ChangeIp2">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list2"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="属类：阶段代码（可选）">
              <el-radio-group v-model="radio3" @change="ChangeIp3">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list3"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="属类：专业代码（可选）">
              <el-radio-group v-model="radio4" @change="ChangeIp4">
                <el-radio-button
                  :label="item.title"
                  v-for="item in list4"
                  :key="item.id"
                ></el-radio-button>
              </el-radio-group>
            </el-form-item>
          </div>
          <div class="login-btn">
            <el-button @click="outerVisible = false">取 消</el-button>
            <el-button type="primary" @click="category('classForm')"
              >添加分类</el-button
            >
          </div>
        </el-form>
      </el-dialog>
      <el-dialog
        title="问题标记"
        class="textares"
        :visible.sync="dialogVisible"
        width="25%"
      >
        <el-autocomplete
          class="inline-input"
          v-model="problemFrom.problem"
          type="textarea"
          :fetch-suggestions="querySearch"
          placeholder="请输入内容"
          @select="handleSelect"
        ></el-autocomplete>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="problemFromBtn">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="文字替换" :visible.sync="Substitution" width="30%">
        <el-form :model="Substitutionform">
          <el-form-item label="属性" :label-width="formLabelWidth">
            <el-radio v-model="Substitutionform.type" label="1"
              >档案号</el-radio
            >
            <el-radio v-model="Substitutionform.type" label="2"
              >案卷题名</el-radio
            >
          </el-form-item>
          <el-form-item label="原文字" :label-width="formLabelWidth">
            <el-input
              v-model="Substitutionform.before_str"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item label="替换为" :label-width="formLabelWidth">
            <el-input
              v-model="Substitutionform.after_str"
              autocomplete="off"
            ></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="Substitution = false">取 消</el-button>
          <el-button type="primary" @click="SubstitutionBtn">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog :visible.sync="dialogFiling" width="20%">
        <span>文件已生成</span>
        <span slot="footer" class="dialog-footer">
          <a :href="downloadUrl" :headers="headers">
            <el-button type="primary" @click="Submit">立即下载</el-button>
          </a>
        </span>
      </el-dialog>

      <common-dawer
        v-if="drawer"
        ref="demoDrawer"
        @closeDrawer="closeDrawer"
        :table="tables"
        :num="NUmber"
      ></common-dawer>
    </div>
  </div>
</template>

<script>
import commonInfo from "@/utils/common";
import {
  Classifies,
  bookTitles,
  bookTitlesOne,
  GetTitle,
  BookTitles,
  projectClassify,
  delBookTitles,
  modifyBookTitles,
  seeClassifiesinfo,
  delBookTitlesMore,
  BTitleproblemresolve,
  editProjectClassifies,
  delProjectClassifies,
  BookTitlesproblem,
  Bookcheck,
  exportPage,
  Catalogscheck,
  submitBooktitles,
  batchReplace,
  bookCatalogsExport,
} from "../../../../api/Template/index";
import CommonDawer from "../../../../components/common/commonTab.vue";
import fileDownload from "js-file-download";
export default {
  components: {
    CommonDawer,
  },
  watch: {
    /* 监听当前选中的节点 */
    currentNodeKey(id) {
      // Tree 内部使用了 Node 类型的对象来包装用户传入的数据，用来保存目前节点的状态。可以用 $refs 获取 Tree 实例
      if (id.toString()) {
        this.$refs["tree"].setCurrentKey(id);
      } else {
        this.$refs["tree"].setCurrentKey(null);
      }
    },
    /* 树状图监听搜索 */
    filterText(val) {
      this.$refs.tree.filter(val);
    }, // 监听表格多选事件
  },
  data() {
    return {
      //按钮显示隐藏
      can_operate: "1",
      /*  */
      dialogFiling: false,
      downloadUrl: "",

      /* 判断是否发生改变 */
      ChangeNot: "0",

      clickRow: null, // 当前点击的行
      clickCell: null, // 当前点击的列
      tabClickLabel: "", // 当前点击的列名
      /* 显示几号文 */
      Type: sessionStorage.getItem("type"),
      /* 显示当前位置 */
      now_location: "",

      /* 网址 */
      host: localStorage.getItem("host"),

      /* 头部 */
      headers: {
        Authorization: localStorage.getItem("token"),
      },

      /* 暂存左侧的菜单id */
      Id: "",
      /* 当前选中的节点 */
      currentNodeKey: "",
      /* 表格数据 */
      tableData: [
        /*  {
          project_classify_id: "",
          title: "",
          serial_num: "",
          start_date: "",
          end_date: "",
          page_num: "",
          store_period: "",
          temp_file_no: "",
          sort: "",
          part_company_id: "",
        }, */
      ],
      //暂存案卷目录
      id: "",
      /* 添加分类表单 */
      classForm: {
        id: "",
        title: "",
        parent_id: "",
        template_id: "",
        archives_no: "",
        project_no: "",
        project_id: "",
        part_company_id: "",
        part_company_type: "",
        type: "",
        stage_code: "",
        major_code: "",
      },
      /* 添加分类表单失焦判断 */
      classFormrules: {
        title: [
          {
            required: true,
            message: "请输入分类名称",
            trigger: "blur",
          },
        ],
        archives_no: [
          {
            required: true,
            message: "请输入档案号",
            trigger: "blur",
          },
        ],
      },
      /* 新增档案号组合+种类 */
      radio1: "",
      /* 新增档案号组合+分类 */
      radio2: "",
      /* 新增档案号组合+阶段代码 */
      radio3: "",
      /* 新增档案号组合+专业代码 */
      radio4: "",
      /* 新增档案号组合+圆点 */
      Btn: "•",
      /* 新增档案号组合+斜杠 */
      BTn: "/",
      /* idList: "", */
      /* 新增档案号组合+种类选择器 */
      list1: [
        { id: "1", title: "J" },
        { id: "2", title: "K" },
      ],
      /* 新增档案号组合+分类选择器 */
      list2: [{ id: "1", title: "[项目代码]" }],
      /* 新增档案号组合+阶段代码选择器 */
      list3: [
        { id: "1", title: "1" },
        { id: "2", title: "2" },
        { id: "3", title: "3" },
        { id: "4", title: "4" },
        { id: "5", title: "5" },
        { id: "6", title: "6" },
      ],
      /* 新增档案号组合+专业代码选择器 */
      list4: [
        { id: "1", title: "ZH" },
        { id: "2", title: "XL" },
        { id: "3", title: "LJ" },
        { id: "4", title: "Q" },
        { id: "5", title: "HQ" },
        { id: "6", title: "S" },
        { id: "7", title: "Z" },
        { id: "8", title: "J" },
        { id: "9", title: "L" },
        { id: "10", title: "DC" },
        { id: "11", title: "SH" },
        { id: "12", title: "TX" },
        { id: "13", title: "XH" },
        { id: "14", title: "D" },
        { id: "15", title: "DH" },
        { id: "16", title: "XX" },
        { id: "17", title: "F" },
        { id: "18", title: "HB" },
        { id: "19", title: "DM" },
        { id: "20", title: "ZY" },
        { id: "21", title: "RF" },
        { id: "22", title: "LL" },
        { id: "23", title: "JL" },
      ],
      /* 新增种类数组 */
      arr1: ["J", "K"],
      /* 新增分类数组 */
      arr2: ["[项目代码]"],
      /* 新增阶段代码数组 */
      arr3: ["1", "2", "3", "4", "5", "6"],
      /* 新增专业代码数组 */
      arr4: [
        "Z",
        "F",
        "Q",
        "D",
        "S",
        "J",
        "L",
        "ZH",
        "XL",
        "LJ",
        "SH",
        "TX",
        "XH",
        "HQ",
        "DH",
        "XX",
        "HB",
        "DM",
        "DC",
        "ZY",
        "RF",
        "LL",
        "JL",
      ],
      /* 添加分类蒙尘 */
      outerVisible: false,
      //树状图编辑
      editF: {
        title: "",
        project_no: "",
        archives_no: "",
        type: "",
        stage_code: "",
        major_code: "",
      },
      /* 编辑档案号组合 +种类 */
      val1: "",
      /* 编辑档案号组合 +分类 */
      val2: "",
      /* 编辑档案号组合 +阶段代码 */
      val3: "",
      /* 编辑档案号组合 +专业代码 */
      val4: "",
      /* 编辑分类蒙尘 */
      dialogVisibleAmend: false,
      //列表点击行的index
      tabClickIndex: null,
      /* 获取树状图的数据 */
      IDS: {
        part_company_id: "",
      },
      /* 卷内导出传递的值 */
      juanneiIDS: {
        project_classify_id: "",
        book_title_ids: "",
        part_company_id: "",
      },
      //树状图搜索
      filterText: "",
      //导入蒙层
      drawer: false,
      //树状图数据
      data: [],
      /* 树状图的子集和标题 */
      defaultProps: {
        children: "children",
        label: "title",
      },
      /* 删除 */
      delList: {
        ids: "",
        part_company_id: this.$route.query.companyId,
        project_classify_id: sessionStorage.getItem("clickTd"),
      },

      //批量PDF上传
      pdfList: {
        file_urls: [],
        project_classify_id: "",
        part_company_id: this.$route.query.companyId,
      },
      /* 提交案卷目录表单 */
      Submissionfrom: {
        project_id: "",
        part_company_id: "",
        project_classify_id: "",
        book_title_ids: "",
        select_all: "",
      },
      /* 文字替换 */
      Substitutionform: {
        part_company_id: "", //参见单位id
        project_classify_id: "", //项目分类id
        book_title_ids: [], //案卷数组
        select_all: 1, //是否全选
        type: "", //1档案号，2案卷题名
        before_str: "", //需替换的
        after_str: "", //替换为
      },
      /* 文字替换蒙尘 */
      Substitution: false,
      //页数
      pageSizeArr: JSON.parse(JSON.stringify(commonInfo.pageSizeArr)),
      /* 当前页 */
      current_page: 1,
      /* 总条数 */
      total: 0,
      /* 加载页面 */
      isLoading: true,
      //新增蒙案卷目录
      form: {
        project_classify_id: "",
        id: "",
        part_company_id: "",
        title: "案卷目录",
        start_end_date: "20170719~20190420",
        page_num: "10",
        word_material: "",
        blueprint: "0",
        store_period: "3",
        remark: "3",
        cabin_no: "3",
      },
      /* 表单宽度 */
      formLabelWidth: "120px",
      /* 时间期限 */
      options: [
        { id: 1, title: "永久" },
        { id: 2, title: "10年" },
        { id: 3, title: "3年" },
      ],
      //问题标记蒙尘
      dialogVisible: false,
      /* 输入建议框的建议数组 */
      restaurants: [],
      /* 提交错误的输入框的绑定值 */
      problemFrom: {
        ids: "",
        problem: "",
        project_classify_id: sessionStorage.getItem("clickTd"),
        part_company_id: this.$route.query.companyId,
      },
      /* 表格编辑表单 */
      editForm: {},
      //案卷导入传递的值
      iDS: {
        project_classify_id: "",
        part_company_id: "",
        per_page: 10,
        page: 1,
      },
      /* 案卷目录检查提供的值 */
      inspect: {
        project_classify_id: "",
        part_company_id: "",
      },
      //传递值的名字
      tables: {},
      //区分卷内导入和案卷导入的值
      NUmber: "",
      //卷内导入传递的值
      juannei: {
        project_classify_id: "",
        part_company_id: this.$route.query.companyId,
      },
      /*    BeiKaoB: {
        book_title_id: "",
      }, */
      /* 导出备考表数据 */
      BeiKaoBs: {
        book_title_ids: "",
        project_classify_id: "",
        part_company_id: this.$route.query.companyId,
        type: "",
      },
      //搜索传递的值
      froms: {
        project_classify_id: sessionStorage.getItem("clickTd"),
        part_company_id: this.$route.query.companyId,
        keyword: "",
        per_page: 10,
        page: 1,
      },
    };
  },

  methods: {
    /* 关闭或开启导入蒙尘 */
    closeDrawer(value) {
      this.drawer = value;
    },
    //清空数据
    setValueNull(val) {
      this.radio1 = "";
      this.radio2 = "";
      this.radio3 = "";
      this.radio4 = "";
      this.val1 = "";
      this.val2 = "";
      this.val3 = "";
      this.val4 = "";
    },
    /* 新增档案号组合+圆点改变 */
    ChangeIp() {
      this.classForm.archives_no = this.classForm.archives_no + this.Btn;
      this.editF.archives_no += this.Btn;
      this.changeDang();
    },
    /* 新增档案号组合+斜杠改变 */
    ChangeIps() {
      this.classForm.archives_no = this.classForm.archives_no + this.BTn;
      this.editF.archives_no += this.BTn;
      this.changeDang();
    },
    /* 新增档案号组合+种类改变 */
    ChangeIp1() {
      this.classForm.archives_no = this.classForm.archives_no + this.radio1;
      this.classForm.type = this.radio1;
      this.editF.archives_no += this.val1;
      this.editF.type = this.val1;
      this.changeDang();
    },
    /* 新增档案号组合+分类改变 */
    ChangeIp2() {
      this.classForm.archives_no = this.classForm.archives_no + this.radio2;
      this.classForm.project_no = this.radio2;
      this.editF.archives_no += this.val2;
      this.editF.project_no = this.val2;
      this.changeDang();
    },
    /* 新增档案号组合+阶段代码改变 */
    ChangeIp3() {
      this.classForm.archives_no = this.classForm.archives_no + this.radio3;
      this.classForm.stage_code = this.radio3;
      this.editF.archives_no += this.val3;
      this.editF.stage_code = this.val3;
      this.changeDang();
    },
    /* 新增档案号组合+专业代码改变 */
    ChangeIp4() {
      this.classForm.archives_no = this.classForm.archives_no + this.radio4;
      this.classForm.major_code = this.radio4;
      this.editF.archives_no += this.val4;
      this.editF.major_code = this.val4;
      this.changeDang();
    },
    //添加分类目录提交
    category(formName) {
      this.classForm.template_id = this.$route.query.template_id;
      this.classForm.id = this.$route.query.companyId;
      this.classForm.type = this.radio1;
      this.classForm.project_id = this.$route.query.project_id;
      this.classForm.project_no = this.radio2;
      this.classForm.stage_code = this.radio3;
      this.classForm.major_code = this.radio4;
      console.log(this.classForm);
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let res = await projectClassify(this.classForm);
          console.log(res);
          if (res.data.code == 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });
            this.$refs[formName].resetFields();
            this.outerVisible = false;
            this.loadData();
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        }
      });
    },
    //多选
    handleSelectionChange(val) {
      this.multipleSelection = val;

      console.log(this.multipleSelection);
    },
    //问题标记
    ProblemMark() {
      if (this.multipleSelection == null) {
        this.$message({
          showClose: true,
          duration: 3000,

          message: "请先选中要标记的问题",
          type: "error",
        });
      } else {
        this.dialogVisible = true;
      }
    },
    async problemFromBtn() {
      let arr = this.multipleSelection.map((item) => item.id);
      // console.log(arr);
      let ids = arr.join(",");
      this.problemFrom.ids = ids;
      let res = await BookTitlesproblem(this.problemFrom);
      console.log(res);
      if (res.data.code === 200) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "success",
        });
        this.loadData2(this.iDS);
        this.dialogVisible = false;
      } else {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "error",
        });
      }
    },
    //多选删除
    deleteSelectItem() {
      if (this.multipleSelection == null) {
        this.$message({
          showClose: true,
          duration: 3000,

          message: "请先选中要删除的数据哦！ 亲",
          type: "error",
        });
      } else {
        this.$confirm("请谨慎操作，删除后不可恢复！！！", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          let arr = this.multipleSelection.map((item) => item.id);
          // console.log(arr);
          this.delList.ids = arr.join(",");
          // console.log(ids);
          let res = await delBookTitlesMore(this.delList);
          // console.log(res);
          if (res.data.code === 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });

            this.loadData2(this.iDS);
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        });
      }
    },
    //树状图删除
    remove(node, data) {
      console.log(node, data);
      const current = node.childNodes;
      if (current.length == "0") {
        this.$confirm("确认删除？")
          .then(async (_) => {
            console.log(data.id);
            let id = data.id;
            let part_company_id = this.$route.query.companyId;
            console.log(id);
            let res = await delProjectClassifies({ id, part_company_id });
            console.log(res);
            if (res.data.code === 200) {
              this.$message({
                showClose: true,
                duration: 3000,
                message: res.data.msg,
                type: "success",
              });

              this.loadData();
            } else {
              this.$message({
                showClose: true,
                duration: 3000,
                message: res.data.msg,
                type: "error",
              });
            }
          })
          .catch((_) => {});
      } else {
        this.$message({
          showClose: true,
          duration: 3000,
          message: "此部门还有子部门，不支持删除",
          type: "warning",
        });
      }
    },
    //遍历数组查看档案号内是否有该数组的数据
    changeDang() {
      console.log(this.classForm.archives_no, "rt");
      let str = this.classForm.archives_no;
      let str1 = str.substring(0, 2);
      let str2 = str.substring(str.indexOf("•", str.indexOf("•") + 1) + 1);
      console.log(str2, "231");
      for (let item of this.arr1) {
        if (str1.indexOf(item) != -1) {
          this.radio1 = item;
          console.log(item);
          console.log("8", this.radio1);
        } /* else if (str1.indexOf(item) == -1) {
          this.radio1 = "";
          console.log(1);
        } */
      }
      for (let item of this.arr2) {
        if (str.indexOf(item) != -1) {
          this.radio2 = item;
          console.log(item);
        } /* else if (str.indexOf(item) == -1) {
          this.radio2 = "";
          console.log(2);
        } */
      }
      for (let item of this.arr3) {
        if (str.indexOf(item) != -1) {
          this.radio3 = item;
        } /* else if (str.indexOf(item) == -1) {
          this.radio3 = "";
        } */
      }
      for (let item of this.arr4) {
        if (str2.indexOf(item) != -1) {
          this.radio4 = item;
          console.log(item);
        } /* else if (str2.indexOf(item) == -1) {
          this.radio4 = "";
        } */
      }
    },
    //树形编辑
    async Edit(node, data) {
      if (data.is_can_edit == 0) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: "抱歉，您没有这个权限",
          type: "error",
        });
      } else {
        this.editF = {};
        this.dialogVisibleAmend = true;
        console.log(data.id);
        let id = data.id;
        let project_id = this.$route.query.project_id;
        let res = await seeClassifiesinfo({ id, project_id });
        console.log(res);
        this.editF = res.data.data;
        console.log(this.editF);
        this.val1 = this.editF.type;
        this.val2 = this.editF.project_no;
        this.val3 = this.editF.stage_code;
        this.val4 = this.editF.major_code;
      }
    },
    /* 导出卷内页码 */
    async Pagevolume() {
      this.$loading();
      let part_company_id = this.$route.query.companyId;
      let project_classify_id = sessionStorage.getItem("clickTd");
      let res = await exportPage({ part_company_id, project_classify_id });
      console.log(res);
      if (res.data.code === 200) {
        this.$loading().close();
        this.dialogFiling = true;
        this.downloadUrl = res.data.data.download_url;
      } else {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "error",
        });
      }
    },
    Submit() {
      this.dialogFiling = false;
    },
    //表格删除
    deleteRow(id) {
      let part_company_id = this.$route.query.companyId;
      let project_classify_id = sessionStorage.getItem("clickTd");
      this.$confirm("请谨慎操作，删除后不可恢复！！！", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(async () => {
        let res = await delBookTitles({
          id,
          part_company_id,
          project_classify_id,
        });
        //console.log(res);
        if (res.data.code === 200) {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "success",
          });
          this.loadData2(this.iDS);
        } else {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "error",
          });
        }
      });
    },
    /* 表格选中获取当前信息 */
    handleClick(row, column, event) {
      console.log(row, column, event, "dfd");
      this.goInvolume(row);
    },
    /* 批量导入pdf */
    fileUPList() {
      this.pdfList.project_classify_id = sessionStorage.getItem("clickTd");
      this.tables = this.pdfList;
      this.drawer = true;
      this.NUmber = "filepdfList";
      this.$nextTick(() => {
        this.$refs.demoDrawer.open2();
      });
    },

    //树形添加
    async append(data) {
      this.classForm.part_company_id = this.$route.query.companyId;
      console.log("data:", data);

      if (data.archives_no != undefined) {
        this.classForm.archives_no = data.archives_no;
      }
      this.outerVisible = true;
      let id = data.id;
      let project_id = this.$route.query.project_id;
      this.classForm.part_company_type = data.part_company_type;
      let res = await seeClassifiesinfo({ id, project_id });

      this.setValueNull();
      this.classForm.template_id = this.$route.query.template_id;
      this.classForm.parent_id = data.classify_id;
      this.radio1 = res.data.data.type;
      this.radio2 = res.data.data.project_no;
      this.radio3 = res.data.data.stage_code;
      this.radio4 = res.data.data.major_code;
    },
    /* 获取当前树状图数据 */
    async loadData() {
      console.log(1);
      /*   this.IDS.template_id = this.$route.query.template_id; */
      this.IDS.part_company_id = this.$route.query.companyId;
      let res = await Classifies(this.IDS);
      console.log(res, "1234");
      this.data = res.data.data.list;
      this.now_location = res.data.data.now_location;
      this.can_operate = res.data.data.can_operate;
      this.$nextTick(() => {
        // myTree 数组件的ref  默认让第一项高亮
        // data是树组件对应的数据
        // 通过data中的第一项的id找到对应的节点，然后把这个节点设置为高亮
        this.$refs["tree"].setCurrentKey(sessionStorage.getItem("clickTd"));
        console.log(111);
      });
    },
    /* 获取表格数据 */
    async loadData2(num) {
      this.iDS.part_company_id = this.$route.query.companyId;
      this.iDS.project_classify_id = sessionStorage.getItem("clickTd");
      this.inspect.part_company_id = this.$route.query.companyId;
      console.log(this.iDS, "121");
      this.iDS = num;
      let res = await BookTitles(num);
      console.log(res, "111");
      this.tableData = res.data.data.data;
      this.total = res.data.data.total;
      this.current_page = res.data.data.current_page;
      this.isLoading = false;
    },
    //案卷列表检查
    async InspectAn() {
      this.inspect.project_classify_id = sessionStorage.getItem("clickTd");
      if (!this.inspect.project_classify_id) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: "请在左侧菜单指定项目分类",
          type: "error",
        });
      } else {
        const loading = this.$loading({
          lock: true,
          text: "正在检查，请稍候",
          spinner: "el-icon-loading",
          background: "rgba(0, 0, 0, 0.7)",
        });
        let res = await Bookcheck(this.inspect);
        console.log(res, "1123");
        if (res.data.code === 200) {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "success",
          });
          loading.close();
        } else {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "error",
          });
          loading.close();
        }
      }
    },
    /* 提交案卷 */
    async Submission() {
      // 显示loading
      this.$loading();
      this.Submissionfrom.project_id = this.$route.query.project_id;
      this.Submissionfrom.part_company_id = this.$route.query.companyId;
      this.Submissionfrom.project_classify_id =
        sessionStorage.getItem("clickTd");
      this.Submissionfrom.book_title_ids = [];
      if (this.multipleSelection == null) {
        this.Submissionfrom.select_all = "1";
      } else {
        this.Submissionfrom.select_all = "0";
        let arr = this.multipleSelection.map((item) => item.id);
        this.Submissionfrom.book_title_ids = arr;
      }
      console.log(this.Submissionfrom);
      let res = await submitBooktitles(this.Submissionfrom);
      console.log(res);
      if (res.data.code === 200) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "success",
        });
        this.$loading().close();
      } else {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "error",
        });
        this.$loading().close();
      }
    },
    /* 问题已解决 */
    Problemsolving(row) {
      this.$confirm("问题已解决？")
        .then(async (_) => {
          let id = row.id;
          let part_company_id = this.$route.query.companyId;
          let project_classify_id = sessionStorage.getItem("clickTd");
          let res = await BTitleproblemresolve({
            id,
            part_company_id,
            project_classify_id,
          });
          console.log(res);
          if (res.data.code === 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });
            this.loadData2(this.iDS);
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        })
        .catch((_) => {
          console.log(2);
        });
    },
    //案卷导入
    showAn() {
      this.tables = this.iDS;
      this.NUmber = "anjuan29";
      this.drawer = true;
      this.$nextTick(() => {
        this.$refs.demoDrawer.open2();
      });
    },
    //卷内导入
    showjuan() {
      this.juannei.project_classify_id = sessionStorage.getItem("clickTd");
      this.tables = this.juannei;
      this.NUmber = "juannei29";
      this.drawer = true;
      this.$nextTick(() => {
        this.$refs.demoDrawer.open2();
      });
      /*  } */
    },
    /* 表格搜索 */
    INput() {
      if (this.froms.keyword == "") {
        this.loadData2(this.iDS);
      }
    },
    //搜索
    async goSearch() {
      this.$loading();
      this.froms.page = 1;
      this.froms.per_page = 10;
      this.current_page = 1;
      console.log(this.froms);
      if (this.froms.keyword == "") {
        this.$message.warning("查询条件不能为空！");
        return;
      }
      let res = await BookTitles(this.froms);
      console.log(res, "123");
      this.tableData = res.data.data.data;
      this.total = res.data.data.total;
      this.current_page = res.data.data.current_page;
      this.$loading().close();
    },
    //案卷导出
    async Goexport() {
      this.Id = sessionStorage.getItem("clickTd");
      console.log(this.Id);
      if (!this.Id) {
        this.$message({
          showClose: true,
          duration: 3000,
          showClose: true,
          duration: 3000,
          message: "请在左侧菜单指定项目分类",
          type: "error",
        });
      } else {
        // 显示loading
        this.$loading();
        let project_classify_id = this.Id;
        console.log(project_classify_id);
        let res2 = await GetTitle({ project_classify_id });
        console.log(res2);
        if (res2.data.code == 200) {
          this.$axios({
            method: "post",
            url: "/api/book_titles/export",
            headers: {
              Token: localStorage.getItem("token"),
            },
            processData: false,
            contentType: false,
            data: this.iDS,
            responseType: "blob",
          }).then((res) => {
            console.log(res);
            fileDownload(res.data, res2.data.data.title + ".xlsx");
            this.$loading().close();
          });
        }
      }
    },
    Substitu() {
      this.Substitution = true;
      this.Substitutionform.part_company_id = this.$route.query.companyId;
      this.Substitutionform.project_classify_id =
        sessionStorage.getItem("clickTd");
      if (
        this.multipleSelection == undefined ||
        this.multipleSelection.length == 0
      ) {
        this.Substitutionform.select_all = 1;
      } else if (this.multipleSelection.length > 0) {
        this.Substitutionform.select_all = 0;
        this.Substitutionform.book_title_ids = this.multipleSelection.map(
          (item) => item.id
        );
      }
    },
    /* 文字替换 */
    async SubstitutionBtn() {
      // 显示loading
      this.$loading();
      console.log(this.Substitutionform);
      let res = await batchReplace(this.Substitutionform);
      console.log(res);
      if (res.data.code === 200) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "success",
        });
        this.Substitution = false;
        this.loadData2(this.iDS);
        this.$loading().close();
      } else {
        this.$message({
          showClose: true,
          duration: 3000,
          message: res.data.msg,
          type: "error",
        });
        this.$loading().close();
      }
    },
    //卷内导出
    async InGoexport() {
      if (
        this.multipleSelection == undefined ||
        this.multipleSelection.length == 0
      ) {
        this.$message({
          showClose: true,
          duration: 3000,

          message: "请先选中要导出的卷内的案卷哦！ 亲",
          type: "error",
        });
      } else {
        // 显示loading
        this.$loading();
        let arr = this.multipleSelection.map((item) => item.id);
        setTimeout(() => {
          this.$loading().close();
        }, 500);
        this.$message({
          showClose: true,
          duration: 3000,
          message: "下载任务已添加~",
          type: "success",
        });
        // console.log(arr);
        let ids = arr.join(",");
        this.Id = sessionStorage.getItem("clickTd");
        this.juanneiIDS.project_classify_id = this.Id;
        this.juanneiIDS.part_company_id = this.$route.query.companyId;
        this.juanneiIDS.book_title_ids = ids;
        let res = await bookCatalogsExport(this.juanneiIDS);
        console.log(res);
      }
    },
    //导出备考表
    preparationFrom(num) {
      console.log(this.multipleSelection);
      if (
        this.multipleSelection == undefined ||
        this.multipleSelection.length == 0
      ) {
        this.$message({
          showClose: true,
          duration: 3000,

          message: "请先选中要导出的案卷哦！ 亲",
          type: "error",
        });
      } else {
        // 显示loading
        this.$loading();
        console.log(this.multipleSelection);
        console.log(this.multipleSelection.length);
        let arr = this.multipleSelection.map((item) => item.id);
        // console.log(arr);
        let ids = arr.join(",");
        let title = "";
        if (num == 1) {
          title = "卷内备考表";
        } else if (num == 2) {
          title = "案卷封面";
        } else if (num == 3) {
          title = "盒子封面";
        }
        console.log(ids);
        this.BeiKaoBs.book_title_ids = ids;
        this.BeiKaoBs.project_classify_id = sessionStorage.getItem("clickTd");
        this.BeiKaoBs.type = num;
        this.$axios({
          method: "get",
          url: "api/export_word/to_zip",
          headers: {
            Token: localStorage.getItem("token"),
          },
          processData: false,
          contentType: false,
          params: this.BeiKaoBs,
          responseType: "blob",
        }).then((res) => {
          console.log(res);
          fileDownload(res.data, title + ".zip");
          this.$loading().close();
        });
      }
    },
    //分页
    handleCurrentChange(val) {
      this.current_page = val;
      this.froms.page = val;
      this.loadData2(this.froms);
    },
    //分页
    handleSizeChange(val) {
      this.froms.per_page = val;
      this.loadData2(this.froms);
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.title.indexOf(value) !== -1;
    },
    //树状图被点击时
    handleNodeClick(data) {
      console.log(data, "1");
      /*  this.id = data.classify_id; */
      /*  this.form.project_classify_id = data.title; */
      sessionStorage.setItem("clickTd", data.id);
      sessionStorage.setItem("currentNodeKey", data.id);
      this.loadData2(this.iDS);
    },

    // 控制input显示 row 当前行 column 当前列
    tabClick(row, column, cell, event) {
      var that = this;
      switch (column.label) {
        case "案卷题名":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "起止日期":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "页次":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "文字材料":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "蓝图":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "保管期限":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "柜号":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "档案号":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "备注":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        case "临时档号":
          that.clickRow = row.index;
          that.clickCell = column.index;
          that.tabClickLabel = column.label;
          break;
        default:
          return;
      }
    },
    // 把每一行的索引放进row
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex;
      if (row.data_count == 0) {
        return "warning-row";
      }
      return "";
    },

    // 把每一列的索引放进column
    tableCellClassName({ column, columnIndex }) {
      column.index = columnIndex;
    },
    /* 点击表格获取当前的信息 */
    Rowclick(row) {
      console.log(row);
      this.editForm = row;
    },
    /* 编辑分类 */
    editModify(formName) {
      this.$refs[formName].validate(async (valid) => {
        //console.log(valid);
        if (valid) {
          let res = await editProjectClassifies(this.editF);
          console.log(res);
          if (res.data.code === 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });
            this.loadData();
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        }
        this.dialogVisibleAmend = false;
      });
    },
    /* 判断是否发生改变 */
    inputFocus() {
      this.ChangeNot = "1";
    },
    // 失去焦点初始化
    async inputBlur() {
      this.editForm.part_company_id = this.$route.query.companyId;
      this.editForm.project_classify_id = sessionStorage.getItem("clickTd");
      if (this.can_operate == "1" && this.ChangeNot == "1") {
        console.log(this.editForm, "121");
        let res = await modifyBookTitles(this.editForm);
        console.log(res);
        if (res.data.code == 200) {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "success",
          });
          this.loadData2(this.iDS);
          this.ChangeNot = "0";
        } else {
          this.$message({
            showClose: true,
            duration: 3000,
            message: res.data.msg,
            type: "error",
          });
          this.loadData2(this.iDS);
          this.ChangeNot = "0";
        }
      }
    },

    //跳转到卷内目录
    goInvolume(row) {
      console.log(row);
      /*    sessionStorage.setItem("title", row.title);
      sessionStorage.setItem("classtitle", row.project_classify_id); */
      this.$router.push({
        path: "/project/template-item/filing/construction/volumeDirectorytwentynine",
        query: {
          id: row.id,
          ProjectClass: sessionStorage.getItem("clickTd"),
          template_id: this.$route.query.template_id,
          companyId: this.$route.query.companyId,
          xsyc: this.can_operate,
        },
      });
    },
    //新增方法
    async addClick() {
      console.log(1);
      this.form.part_company_id = this.$route.query.companyId;
      this.form.project_classify_id = sessionStorage.getItem("clickTd");
      if (!this.form.project_classify_id) {
        this.$message({
          showClose: true,
          duration: 3000,
          message: "请在左侧菜单指定项目分类",
          type: "error",
        });
      } else {
        console.log(this.multipleSelection);
        if (this.multipleSelection == undefined) {
          this.form.id = "";
          let res = await bookTitles(this.form);
          console.log(res);
          if (res.data.code == 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });
            this.loadData2(this.iDS);
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        } else if (this.multipleSelection.length == 1) {
          this.form.id = this.multipleSelection[0].id;
          let res = await bookTitlesOne(this.form);
          console.log(res);
          if (res.data.code == 200) {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "success",
            });
            this.loadData2(this.iDS);
          } else {
            this.$message({
              showClose: true,
              duration: 3000,
              message: res.data.msg,
              type: "error",
            });
          }
        } else if (this.multipleSelection.length > 1) {
          this.$message({
            showClose: true,
            duration: 3000,
            message: "只能选择一个",
            type: "error",
          });
        }
      }
    },
    /* 多选输入框返回输入建议的方法 */
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },
    loadAll() {
      return [
        { id: "1", value: "案卷题名重复" },
        { id: "2", value: "页号错误" },
        { id: "3", value: "日期错误" },
        { id: "4", value: "底图错误" },
        { id: "5", value: "档案号错误" },
        { id: "6", value: "页册错误" },
      ];
    },
    handleSelect(item) {
      console.log(item);
    },
  },
  /*  mounted: function () {
    this.loadData();
  }, */

  created() {
    this.loadData();
    this.loadData2(this.iDS);
    this.restaurants = this.loadAll();
    console.log(sessionStorage.getItem("currentNodeKey"), "123123");
  },
};
</script>

<style scoped lang="less">
@import "../../../../assets/css/tree.less";
.top {
  margin: 10px 0;
  display: flex;
  P {
    line-height: 40px;
    font-size: 14px;
    margin: 0 10px;
  }
}
.container {
  display: flex;
}
.container-left {
  width: 300px;
  /deep/.treePlate .el-input {
    width: 240px !important;
  }

  .treePlate {
    width: 300px;
    border-right: 1px solid #dddddd;
    overflow-y: scroll;

    .el-input {
      width: 320px;
      margin-bottom: 10px;
    }
  }
  .input-top {
    display: flex;
  }
}
.container-right {
  flex: 1;
  min-width: 500px;
  margin-left: 20px;
}
/deep/.el-table__header {
  margin-bottom: 20px;
  line-height: 40px;
}
/deep/.el-table {
  background-color: #f3f5fb;
}
/deep/.el-table .cell {
  display: flex;
}
/deep/.table .el-button--mini {
  font-size: 18px !important;
  padding: 7px 5px;
  margin-left: 5px;
}
.tab {
  /deep/
    .el-form-item.is-required:not(.is-no-asterisk)
    > .el-form-item__label:before {
    display: none;
  }

  /deep/ .el-input {
    float: left;
    margin-right: 20px;
  }

  /deep/ .el-form-item__content {
    height: 32px;
  }

  .login-btn {
    margin-top: 80px;
    margin-left: 60px;
    display: flex;
    justify-content: space-around;
  }

  .login-btn button {
    width: 30%;
    height: 36px;
    margin-bottom: 10px;
  }
}
.IPBT {
  .el-input {
    width: 72%;
  }
}
.Btn {
  padding: 10px 15px;
  border-radius: 5%;
  border: 1px solid #ccc;
  cursor: pointer;
}

/deep/.el-radio-button__inner {
  padding: 7px 7px;
}
.login-btn {
  display: flex;
  justify-content: space-around;
}
/deep/.el-table .el-table__cell.is-center {
  text-align: center;
}
.el-date-editor--daterange.el-input__inner {
  width: 316px;
}
/deep/.el-table .cell {
  padding-left: 5px;
  padding-right: 5px;
}
/deep/.el-table .el-table__cell {
  padding: 2px 0px;
}
.InputTit {
  width: 97%;
}
.InputTits {
  width: 200px;
}
.table {
  /deep/.el-input--mini .el-input__inner {
    height: 32px;
    font-size: 14px;
  }
}
/deep/.el-input__suffix {
  right: 10px;
}
/deep/.el-input--suffix .el-input__inner {
  padding-right: 14px;
}
/deep/.el-input__inner {
  padding: 0 8px;
}
/deep/.commontop-left .el-input__inner {
  padding: 0 30px;
}
/deep/.table[data-v-37ab2b9a] .el-input--mini .el-input__inner {
  height: 40px;
  font-size: 12px;
}
.el-table td.el-table__cell div {
  width: 100%;
}
/deep/.el-textarea__inner {
  padding: 2px 2px;
  font-size: 14px;
}
.textares {
  /deep/.el-textarea__inner {
    width: 350px;
  }
}
.icons {
  color: red;
  font-size: 16px;
}
// 滚动条的宽度
/deep/ .el-table__body-wrapper::-webkit-scrollbar {
  width: 6px; // 横向滚动条
  height: 6px; // 纵向滚动条 必写
}
// 滚动条的滑块
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
  background-color: #ddd;
  border-radius: 3px;
}

/deep/.el-table .warning-row {
  background: oldlace;
}
</style>